import { lazy } from 'react'
import { Navigate, RouteObject, createBrowserRouter } from 'react-router-dom'
import Layout from '@/page/layout/layout'


const ErrorPage = lazy(() => import('@/page/error-page/error-page'))
const About = lazy(() => import('@/page/about/about'))
const Login = lazy(() => import('@/page/login/login'))
// type routerType = ReturnType<typeof createBrowserRouter> 
// const routes: routerType = createBrowserRouter([{
//     path: '/',
//     element: <Navigate to="/index" />
// }, {
//     id: 'index',
//     path: '/index',
//     element: <Layout />
// }, {
//     id: 'errorPage',
//     path: '/error-page',
//     element: <ErrorPage />,
// }])
const routes: RouteObject[] = [{
    path: '/',
    element: <Navigate to="/index" />
}, {
    id: 'index',
    path: '/index',
    element: <Layout />,
    children: [{
        id: 'about',
        path: 'about',
        element: <About />,
    }]
}, {
    id: 'errorPage',
    path: '/error-page',
    element: <ErrorPage />,
}, {
    id: 'login',
    path: '/login',
    element: <Login />,
}]

export default routes
